<?php
    /**
     *  Copyright (c) 2013, advert-m102 Team
     *  All rights reserved.
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions are met:
     *   1. Redistributions of source code must retain the above copyright
     *      notice, this list of conditions and the following disclaimer.
     *   2. Redistributions in binary form must reproduce the above copyright
     *      notice, this list of conditions and the following disclaimer in the
     *      documentation and/or other materials provided with the distribution.
     *   3. All advertising materials mentioning features or use of this software
     *      must display the following acknowledgement:
     *      This product includes software developed by the advert-m102.
     *   4. Neither the name of the advert-m102 nor the
     *      names of its contributors may be used to endorse or promote products
     *     derived from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY advert-m102 ''AS IS'' AND ANY
     *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     *  DISCLAIMED. IN NO EVENT SHALL advert-m102 BE LIABLE FOR ANY
     *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *
     */

class Html_Social_Media extends Browser
{


    static public  function is_social_media_page(){

        return (isset( $_SESSION['PATHS']['SOCIAL_HEADER']['TITLE']) ? TRUE : FALSE);
    }


    static public function facebook_header()
    {

        return '<meta property="og:title" content="' .  $_SESSION['PATHS']['SOCIAL_HEADER']['TITLE'] . '" />
				<meta property="og:description" content="' .  $_SESSION['PATHS']['SOCIAL_HEADER']['DESCRIPTION'] . '" />
				<meta property="og:site_name" content="' . $_SESSION['PATHS']['SOCIAL_HEADER']['DESCRIPTION'] . '" />
				<meta property="og:type" content="article" />
				<meta property="og:url" content="'.$_SESSION['PATHS']['SOCIAL_HEADER']['URL'].'" />
				<meta property="og:image" content="'.$_SESSION['PATHS']['SOCIAL_HEADER']['IMG'].'" />
				<meta property="og:app_id" content="'.$_SESSION['PATHS']['SOCIAL_HEADER']['FB_APP_ID'].'" />
				';
    }

    static public function facebook_header_body($facebok_app_id = "")
    {

        return '<div id="fb-root"></div>
			<script>(function(d, s, id) {
			  var js, fjs = d.getElementsByTagName(s)[0];
			  if (d.getElementById(id)) return;
			  js = d.createElement(s); js.id = id;
			  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=' . $facebok_app_id . '";
			  fjs.parentNode.insertBefore(js, fjs);
			}(document, "script", "facebook-jssdk"));</script>';
    }

    static public function like($url = "", $style = "")
    {

        return '<div class="fb-like" ' . $style . ' data-href="' . $url . '" data-send="false"
		data-layout="button_count" data-width="450" data-show-faces="false" data-action="like"></div>';
    }


    static public function getTweetUrl($url, $title)
    {
        $maxTitleLength = 140 - (strlen($url) + 1);
        if (strlen($title) > $maxTitleLength) {
            $title = substr($title, 0, ($maxTitleLength - 3)) . '...';
        }

        return "$title " . urlencode($url);
    }

    static public function tweet_this($url = "", $title = "Tweet this !")
    {

        return '<a href="https://twitter.com/share" border="0" class="twitter-share-button" data-url="' . $url . '" data-text="' .
            $title . '">Tweet</a>
			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';

    }


}